// javamaps
// Copyright (c) 2010 Bebeselea Elena
package Data;
import java.util.*;
import java.io.*;

public class ZoomInfo implements Serializable {
    private int rows_;
    private int columns_;
    private Tile[] tiles_;
    private static  int counter_;

    /*
    * Constructori.
    */
    public ZoomInfo(int rows, int columns){
        assert(rows > 0);
        assert(columns > 0);
        // ------------------------------------------------
        rows_ = rows;
        columns_ = columns;
        tiles_ = new Tile[rows * columns];
        counter_ = 0;
    }

    /*
    * Metode publice.
    */
    public int Rows(){ return rows_; }
    public int Columns(){ return columns_; }
    public int Counter(){ return counter_; }
    public Tile[] Tiles(){ return tiles_; }

    //Metoda ce adauga imaginile in ordine, una dupa alta.
    public void AddTile(Tile element){
        assert(counter_ >= 0 && counter_ < rows_ * columns_);
        //-------------------------------------------------------------
        tiles_[counter_] = element;
        counter_++;
    }

    // Metode ce ofera acces la Tiles la nivel de matrice.  
    public void SetTile(int row, int column, Tile element) {
        assert(row >= 0 && row < rows_);
        assert(column >= 0 && column < columns_);
        // ------------------------------------------------
        tiles_[row * columns_ + column] =  element;
    }
    
    public Tile GetTile(int row, int column) {
        assert(row >= 0 && row < rows_);
        assert(column >= 0 && column < columns_);
        // ------------------------------------------------
        return tiles_[row * columns_ + column];
     }

    public Tile GetTile(int index) {
        assert(index >= 0 && index < rows_ * columns_);
        //--------------------------------------------
        return tiles_[index];
    }
}
